package eu.jpereira.trainings.designpatterns.structural.facade;

import eu.jpereira.trainings.designpatterns.structural.facade.model.Book;
import eu.jpereira.trainings.designpatterns.structural.facade.model.Customer;
import eu.jpereira.trainings.designpatterns.structural.facade.model.DispatchReceipt;
import eu.jpereira.trainings.designpatterns.structural.facade.model.Order;
import eu.jpereira.trainings.designpatterns.structural.facade.service.BookDBService;
import eu.jpereira.trainings.designpatterns.structural.facade.service.CustomerDBService;
import eu.jpereira.trainings.designpatterns.structural.facade.service.CustomerNotificationService;
import eu.jpereira.trainings.designpatterns.structural.facade.service.OrderingService;
import eu.jpereira.trainings.designpatterns.structural.facade.service.WharehouseService;

public class DefaultBookstoreFacade implements BookstoreFacade {

	private BookDBService bs;
	private CustomerDBService cs;
	private CustomerNotificationService cns;
	private OrderingService os;
	private WharehouseService ws;
	
	@Override
	public void placeOrder(String customerId, String isbn) {
		Book book = bs.findBookByISBN(isbn);
		Customer customer = cs.findCustomerById(customerId);
		Order order = os.createOrder(customer, book);
		cns.notifyClient(order);
		cns.notifyClient(ws.dispatch(order));
		
	}
	
	public void setBookDBService(BookDBService bs){
		this.bs = bs;
	}
	
	public void setCustomerDBService(CustomerDBService cs){
		this.cs = cs;
	}
	
	public void setCustomerNotificationService(CustomerNotificationService cns){
		this.cns = cns;
	}
	
	public void setOrderingService(OrderingService os){
		this.os = os;
	}
	
	public void setWharehouseService(WharehouseService ws){
		this.ws = ws;
	}

}
